/*
 * Copyright (c) 2008-2021 浩瀚深度 All Rights Reserved.
 *
 * <p>FileName: GlobalExceptionHandler.java</p>
 *
 * @author zz
 * @date 2024/2/7
 * @version 1.0
 * History:
 * v1.0.0 2024/2/7 Create
 */
package com.monitor.base;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>Title: GlobalExceptionHandler</p>
 * <p>Description: </p>
 *
 * @author zz
 */
@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public Result handleException(RuntimeException e) {
        // 通用错误的结果，您可以对不同的异常类型返回不同的状态码和消息
        return new Result(ResultCode.ERROR, null);
    }

//    @ExceptionHandler(value = CustomExceptio.class)
//    @ResponseBody
//    public Result handleCustomException(CustomException e) {
//        // 处理自定义的异常
//        return new Result(e.getCode(), e.getMessage(), null);
//    }
}
